# 主Makefile - 管理整个项目
# 采用头文件引用方式，不生成静态库

# 编译器设置
CC = gcc
CFLAGS = -Wall -Wextra -std=c99 -O2 -g

# 项目配置
PROJECT_NAME = dlsystem-protocol
VERSION = 1.0.0

# 子目录
COMMON_DIR = common
PROTOCOL_104_DIR = protocol/104

# 默认目标
all: common 104-protocol

# 检查通用模块
common:
	@echo "检查通用模块..."
	$(MAKE) -C $(COMMON_DIR)

# 构建104协议模块
104-protocol:
	@echo "构建104协议模块..."
	$(MAKE) -C $(PROTOCOL_104_DIR)

# 清理所有模块
clean:
	@echo "清理所有模块..."
	$(MAKE) -C $(COMMON_DIR) clean
	$(MAKE) -C $(PROTOCOL_104_DIR) clean

# 安装
install: common 104-protocol
	@echo "安装通用模块..."
	$(MAKE) -C $(COMMON_DIR) install
	@echo "安装104协议模块..."
	$(MAKE) -C $(PROTOCOL_104_DIR) install

# 测试
test:
	@echo "运行测试..."
	$(MAKE) -C $(PROTOCOL_104_DIR) test

# 帮助
help:
	@echo "可用目标:"
	@echo "  all          - 构建所有模块 (默认)"
	@echo "  common       - 检查通用模块"
	@echo "  104-protocol - 构建104协议模块"
	@echo "  clean        - 清理所有构建文件"
	@echo "  install      - 安装所有模块"
	@echo "  test         - 运行测试"
	@echo "  help         - 显示此帮助信息"
	@echo ""
	@echo "项目: $(PROJECT_NAME) v$(VERSION)"
	@echo ""
	@echo "注意: 本项目采用头文件引用方式，不生成静态库"

.PHONY: all common 104-protocol clean install test help
